package com.esri.core.geodatabase;

import com.esri.core.geometry.Geometry;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.map.Feature;
import com.esri.core.map.Field;
import com.esri.core.symbol.Symbol;
import com.esri.core.table.FeatureTable;
import com.esri.core.table.TableException;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/* loaded from: classes.dex */
public final class GeopackageFeature implements Feature {
    private Geometry a;
    private GeopackageFeatureTable b;
    private long c;
    protected final Map<String, Object> mAttributes;

    @Override // com.esri.core.map.Feature
    public SpatialReference getSpatialReference() {
        return null;
    }

    @Override // com.esri.core.map.Feature
    public Symbol getSymbol() {
        return null;
    }

    void a(Map<String, Object> map, Geometry geometry, GeopackageFeatureTable geopackageFeatureTable) throws TableException {
        if (map != null) {
            for (String str : map.keySet()) {
                if (geopackageFeatureTable.getField(str) == null) {
                    throw new TableException(str + " not found in schema.");
                }
            }
        }
        if (geometry == null || geometry.getType() == geopackageFeatureTable.getGeometryType()) {
            return;
        }
        throw new TableException("Geometry type of " + geometry.getType() + " does not match table geometry type of " + geopackageFeatureTable.getGeometryType() + ".");
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public GeopackageFeature(long j, Map<String, Object> map, Geometry geometry, GeopackageFeatureTable geopackageFeatureTable) throws TableException {
        this.mAttributes = Collections.synchronizedMap(new LinkedHashMap());
        this.c = j;
        if (map != null) {
            HashMap hashMap = new HashMap();
            for (String str : map.keySet()) {
                hashMap.put(str, map.get(str));
                a(hashMap);
            }
        } else {
            a(map);
        }
        a(geometry);
        this.b = geopackageFeatureTable;
    }

    public GeopackageFeature(Map<String, Object> map, GeopackageFeatureTable geopackageFeatureTable) throws TableException {
        this(-1L, map, null, geopackageFeatureTable);
        a(map, this.a, geopackageFeatureTable);
    }

    public GeopackageFeature(Map<String, Object> map, Geometry geometry, GeopackageFeatureTable geopackageFeatureTable) throws TableException {
        this(-1L, map, geometry, geopackageFeatureTable);
        a(map, geometry, geopackageFeatureTable);
    }

    @Override // com.esri.core.map.Feature
    public Map<String, Object> getAttributes() {
        if (this.mAttributes == null) {
            return null;
        }
        return new LinkedHashMap(this.mAttributes);
    }

    public Object getAttributeValue(Field field) {
        return this.mAttributes.get(field.getName());
    }

    @Override // com.esri.core.map.Feature
    public Object getAttributeValue(String str) {
        return this.mAttributes.get(str);
    }

    @Override // com.esri.core.map.Feature
    public Geometry getGeometry() {
        Geometry geometry = this.a;
        if (geometry == null) {
            return null;
        }
        return geometry;
    }

    @Override // com.esri.core.map.Feature
    public long getId() {
        return this.c;
    }

    public FeatureTable getTable() {
        return this.b;
    }

    private void a(Geometry geometry) {
        this.a = geometry;
    }

    private void a(Map<String, Object> map) {
        if (map != null && map.size() > 0) {
            this.mAttributes.putAll(map);
        } else {
            this.mAttributes.clear();
        }
    }

    public String toString() {
        return "GeopackageFeature [geometry=" + this.a + ", attributes=" + this.mAttributes + ", table=" + this.b + ", oid=" + this.c + "]";
    }
}
